package cc.vicp.djx314.starfood.dao.account;

import org.apache.ibatis.annotations.Param;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;

import cc.vicp.djx314.starfood.domain.account.Account;
import cc.vicp.djx314.starfood.domain.account.User;

public interface UserMapper {
	/**
	 * 创建一个用户
	 * @param user
	 * @param headImg
	 */
	public void createUser(@Param("user") User user, @Param("headImg") byte[] headImg);
	/**
	 * 获取用户头像图像
	 * @param id
	 * @return
	 */
	public Resource getUserHeadImg(Integer id);
	/**
	 * 判断用户的昵称是否存在
	 * @param name
	 * @return
	 */
	public Integer isNickNameExists(String nickName);
	/**
	 * 根据账号名获取user信息
	 * @param accountName
	 * @return
	 */
	public User getUserInfo(String accountName);

	/**
	 * 根据用户id获取用户详细信息
	 * @param userId
	 * @return
	 */
	public User getAllUserInfo(Integer userId);

	/**
	 * 返回除了该用户还持有改昵称的用户数
	 * @param user
	 * @return
	 */
	public Integer getIfOtherUserNickNameExists(User user);

	public int updateUserInfo(User user);

	public int updateUserPhoto(@Param("userId") Integer userId,
			@Param("imageFile") byte[] imageFile);
	
	public int createUserRole(@Param("account") Account account, @Param("roleId") Integer roleId);
}